package com.xiaodaidai.bllogsystem.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Classname MySwagger
 * @Description Swagger接口配置类
 * @Date 2021-3-14 13:14
 * @Created by XiaoDaiDai
 */
@Configuration
@EnableSwagger2
public class MySwagger {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .apis(RequestHandlerSelectors.basePackage("com.xiaodaidai.bootcrm.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("BootCrm的接口文档")
                .description("BootCrm API接口")
                .termsOfServiceUrl("http://www.xiaodaidai.top:14886/")
                .version("1.0")
                .build();
    }
}
